package com.cuteserver.client;

/*
This file is part of Cute-Client.

Cute-Client is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Cute-Client is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with Cute-Client.  If not, see <http://www.gnu.org/licenses/>.
*/

/**
 * A QSException is exception throwable by the cute-client functionalities.
 * 
 * @author Aurelien Deharbe
 * @version 1.0
 */
@SuppressWarnings("serial")
public class CSException extends Exception {

	/**
	 * Default exception messages
	 */
	public static final String UNKNOWN_ERROR = "Unknown error";
	public static final String UNKNOWN_HOST = "Unknown host error";
	public static final String CONNEXION = "Connexion error";
	public static final String BAD_INITIALIZATION = "Bad initialization error";
	public static final String JSON_DECODING = "Json decoding error";
	
	/**
	 * The exception message
	 */
	private String message;
	
	/**
	 * Construct a default cute-client exception
	 */
	public CSException()
	{
		super();
		this.message = UNKNOWN_ERROR;
	}
	
	/**
	 * Construct a cute-client exception
	 * @param message Message describing the exception
	 */
	public CSException(String message)
	{
		super();
		this.message = message;
	}
	
	/**
	 * Get the exception message
	 */
	public String getMessage()
	{
		return message;
	}
	
	/**
	 * Print the exception with its message and its trace
	 */
	public void print()
	{
		System.out.println("QSException : " + this.getMessage());
		this.printStackTrace();
	}
}
